;(function() {
  var id = 0
  function generate(depth = 0, parent = null, totalDepth = 5) {
    let obj = {}
    obj.name = faker.name.title()
    obj.id = `${depth}-${id++}`
    obj.parent = parent ? parent.id : null
    if (depth < totalDepth) {
      var childrenCount = Math.floor(Math.random() * 10)

      var nextDepth = depth + 1
      obj.children = _.range(0, childrenCount).map(() =>
        generate(nextDepth, obj, totalDepth)
      )
    }
    return obj
  }

  var data = generate(0, null, 3)
  console.log({data})
})(window)
